package fangzhiyi_day0321.homework.school;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @author fangzhiyi
 * @version 1.0
 * @date 2025/3/21 21:51
 * @description
 */
public class Test {
    static ArrayList<Student> stu = new ArrayList<Student>();
    static Scanner input = new Scanner(System.in);

    static {
        for (int i = 0; i < 5; i++) {
            System.out.println("请输入第"+(i+1)+"个学生的姓名");
            String name = input.next();
            System.out.println("请输入第"+(i+1)+"个学生的年龄");
            int age = input.nextInt();
            System.out.println("请输入第"+(i+1)+"个学生的性别");
            String sex = input.next();
            System.out.println("请输入第"+(i+1)+"个学生的成绩");
            double score = input.nextDouble();
            stu.add(new Student(name,age,sex,score));
        }
    }

    public static void main(String[] args) {
       while (true){
           System.out.println("1.找出优秀的学生信息(成绩>=80)");
           System.out.println("2.找出没有参加考试的学生的信息");
           System.out.println("3.排除重复的元素");
           System.out.println("4.从高到低打印成绩");
           System.out.println("请输入你的选择");
           int num = input.nextInt();
           switch (num){
               case 1:
                   goodStu();
                   break;
               case 2:
                   nullStu();
                   break;
               case 3:
                    repeat();
                   break;
               case 4:
                    print();
                   break;
               default:
                   System.exit(0);
           }
       }
    }
    public static void goodStu(){
        for (int i = 0; i < stu.size(); i++) {
            if (stu.get(i).getScore()>=80){
                System.out.println("优秀的学生"+stu.get(i));
            }
        }
    }
    public static void nullStu(){
        for (int i = 0; i < stu.size(); i++) {
            if (stu.get(i).getScore()==0){
                System.out.println("没参加考试的学生"+stu.get(i));
            }
        }
    }

    public static void repeat(){
        for (int i = 0; i < stu.size(); i++) {
            for (int j = i+1; j < stu.size(); j++) {
                if ((stu.get(i).getName()).equals(stu.get(j).getName())){
                    stu.remove(j);
                    i--;
                }
            }
        }
    }

    public static void print(){
        for (int i = 0; i < stu.size(); i++) {
            double max = stu.get(0).getScore();

            if (max<stu.get(i).getScore()){

            }
        }

    }
}
